﻿using FlappyGame.View.ViewEx;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FlappyGame.View
{
    public partial class FrmMain : Form
    {
        private System.Timers.Timer _timer;
        public FrmMain()
        {
            InitializeComponent();

            playMap1.GameStopCallback += PlayMap1_GameStopCallback;
            _timer = new System.Timers.Timer();
            _timer.Interval = 5000;
            _timer.Elapsed += _timer_Elapsed;

        }

        private void PlayMap1_GameStopCallback()
        {
            MessageBox.Show("游戏结束");
        }

        private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            playMap1.ExecBeginInvoke(() =>
            {
                playMap1.Focus();
            });
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            playMap1.Focus();
            playMap1.Start();
            _timer.Start();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            playMap1.Stop();
            _timer.Stop();
        }

        private void tbDifficulty_Scroll(object sender, EventArgs e)
        {
            lblDifficulty.Text = tbDifficulty.Value.ToString();
            playMap1.Step = tbDifficulty.Value;
        }
    }
}
